/**
 *  @file StreamReader.h
 */
#ifndef _STREAMREADER_H_
#define _STREAMREADER_H_

#include "Reader.h"
#include "../text/UTFCharConv.h"

namespace cppflib
{

// forward declaration
namespace collections { 
   class BinBuf;
}

namespace io
{

class Stream;

/**
 *  Read characters from a stream
 */
class _DLLAPI StreamReader : public Reader
{
private:
    Stream *pOrgStream;
    text::charset_t charSet;
    collections::BinBuf *pTempBuf;
    collections::ArrayByte *pTempArray;
    wc_t charBuf[2];

private:
    StreamReader(void);
    int ReadOneChar();

public:
    StreamReader(Stream *pStream, text::charset_t cs);
    virtual ~StreamReader(void);

    virtual void Close();
    virtual int Read(collections::ArrayWChar &buffer);
    virtual int Read(collections::ArrayWChar &buffer, int offset, int count);
    virtual int Read();
    virtual i64_t Skip(i64_t charCount);
    virtual sz_t CanReadNoBlocking();
};

} // end of namespace io

} // end of namespace cppflib

#endif
